package com.ek.distmpl.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ek.distmpl.common.model.MsgModel;
import com.ek.distmpl.core.controller.BaseController;


/**
 * 名称：SettingController<br>
 * <p>
 * 描述：系统设置模块<br>
 */
@Controller
@RequestMapping("/common/setting")
public class SettingController extends BaseController {

    @RequestMapping("/manage")
    public String manage(Model model) {
        // 获取系统默认文件上传路径
        String uploadPath = this.propertiesValue("setting.upload");
        model.addAttribute("uploadPath", uploadPath);
        return "/common/setting/manage";
    }

    @RequestMapping("/save")
    @ResponseBody
    public MsgModel save(String uploadPath) {
        String filePath = this.getClass().getResource("/properties/setting.properties").getPath();

        System.out.println(this.readFromFile(filePath));
        String content = "setting.upload=" + uploadPath;
        this.writeToFile(content, filePath);

        return this.resultMsg("保存成功！");
    }

}
